package com.ehome.poct.terminal.service;

import com.ehome.poct.base.api.dto.device.DeviceClinicDTO;
import com.ehome.poct.base.api.feign.DeviceClient;
import com.ehome.poct.core.api.dto.check.OnlineCheckDTO;
import com.ehome.poct.core.api.dto.check.OnlineCheckReqDTO;
import com.ehome.poct.core.api.feign.OnlineCheckClient;
import com.ehome.poct.core.api.feign.PatientClient;
import com.ehome.poct.core.api.vo.online.TodoOrderVO;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class OnlineCheckService {
    @Autowired private PatientClient patientClient;
    @Autowired private OnlineCheckClient onlineCheckClient;
    @Autowired private DeviceClient deviceClient;


    public TodoOrderVO startOnline(OnlineCheckReqDTO onlineReq) {
        OnlineCheckDTO onlineCheckDTO = new OnlineCheckDTO(onlineReq);
        onlineCheckDTO.setPatient(patientClient.getPatient(onlineReq.getPatientId()));
        var dto =new DeviceClinicDTO().setClinicId(onlineReq.getClinicId()).setDeviceType(1);
        var device = deviceClient.getByClinicIdAndType(dto);
        onlineCheckDTO.setDevice(device);
        return onlineCheckClient.startOnline(onlineCheckDTO);
    }

    public List<TodoOrderVO> getTodoList(Long clinicId) {
       return onlineCheckClient.getTodoList(clinicId);
    }

    public Boolean delTodoOrder(Long recordId) {
        return onlineCheckClient.delTodoOrder(recordId);
    }

    public Boolean todoIsExist(Long recordId) {
        return onlineCheckClient.todoIsExist(recordId);
    }

    public Boolean editUniRecord(Long recordId) {
        return onlineCheckClient.editUniRecord(recordId);
    }
}
